<!doctype html>
<html class="no-js" lang="zxx">
<head th:include="/yyyh/include :: header"></head>
<body>

<!-- Preloader -->
<div class="preloader">
    <div class="loader">
        <div class="loader-outter"></div>
        <div class="loader-inner"></div>

        <div class="indicator">
            <svg width="16px" height="12px">
                <polyline id="back" points="1 6 4 6 6 11 10 1 12 6 15 6"></polyline>
                <polyline id="front" points="1 6 4 6 6 11 10 1 12 6 15 6"></polyline>
            </svg>
        </div>
    </div>
</div>
<!-- End Preloader -->


<!-- Header Area -->
<header th:replace="/yyyh/include :: bodyHeader"></header>
<!-- End Header Area -->

<!-- Breadcrumbs -->
<div class="breadcrumbs overlay">
    <div class="container">
        <div class="bread-inner">
            <div class="row">
                <div class="col-12">
                    <h2>医生列表</h2>
                    <ul class="bread-list">
                        <li><a href="/yyyh">主页</a></li>
                        <li><i class="icofont-simple-right"></i></li>
                        <li class="active">医生列表</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- End Breadcrumbs -->

<!-- Start Team -->
<section id="team" class="team section single-page">
    <input type="hidden" id="deptIds" th:value="${deptIds}">
    <div class="container">
        <div style="margin-top: -50px;">
            医生姓名：<input type="text" id="name" /> <button onclick="loadDocList()" class="btn" style="padding: 0.375rem 0.75rem;">搜索</button>
        </div>
        <div class="row" id="docList">

            <!--<div class="col-lg-3 col-md-6 col-12">
                &lt;!&ndash; Single Team &ndash;&gt;
                <div class="single-team">
                    <div class="t-head">
                        <img style="width: 35%;margin-top: 30px;" src="/img/yyyh/head01.jpg" alt="#">
                        <div class="t-icon">
                            <a href="appointment.html" class="btn">预约</a>
                        </div>
                    </div>
                    <div class="t-bottom">
                        <p>外科</p>
                        <h2><a href="###">小明</a></h2>
                    </div>
                </div>
                &lt;!&ndash; End Single Team &ndash;&gt;
            </div>-->

        </div>
    </div>
</section>
<!--/ End Team -->

<!-- Start Newsletter Area -->
<section class="newsletter section">
    <div class="container">
        <div class="row ">
            <div class="col-lg-6  col-12">
                <!-- Start Newsletter Form -->
                <div class="subscribe-text ">
                    <h6>介绍</h6>
                    <p class="">在这里，你可以找到合适的医生<br> 进行预约</p>
                </div>
                <!-- End Newsletter Form -->
            </div>
        </div>
    </div>
</section>
<!-- /End Newsletter Area -->



<div th:replace="/yyyh/include :: bodyFooter"></div>

<script>
    function loadDocList() {
        $('#docList').empty();
        var html = "";
        $.ajax({
            type: "POST",
            url: '/sys/user/listByRole',
            data: {
                'limit': 10,
                'offset': 0,
                'roleId': 60,//医生角色id为60
                'name':$('#name').val(),
                'deptIds':$('#deptIds').val()
            },
            async: false,
            success: function (data) {
                for (var i = 0; i < data.rows.length; i++) {
                    html += '<div class="col-lg-3 col-md-6 col-12">\n' +
                        '                <!-- Single Team -->\n' +
                        '                <div class="single-team">\n' +
                        '                    <div class="t-head">\n' +
                        '                        <img style="width: 35%;margin-top: 30px;" src="/img/yyyh/head01.jpg" alt="#">\n' +
                        '                        <div class="t-icon">\n' +
                        '                            <a href="/yyyh/doctorDetail?did='+data.rows[i].userId+'" class="btn">详情</a>\n' +
                        '                        </div>\n' +
                        '                    </div>\n' +
                        '                    <div class="t-bottom">\n' +
                        '                        <p>'+getDeptNameById(data.rows[i].deptId)+'</p>\n' +
                        '                        <h2><a href="###">'+data.rows[i].name+'</a></h2>\n' +
                        '                    </div>\n' +
                        '                </div>\n' +
                        '                <!-- End Single Team -->\n' +
                        '            </div>';
                }
                $('#docList').append(html);
            }
        });
    }

    /**
     * 获取部门列表（充当缓存作用，如果每行数据都发一次请求就太浪费了）
     * @author qichao
     * @date 2022/4/29
     */
    var deptList;
    function loadDeptList(){
        $.ajax({
            url : "/system/sysDept/list",
            type : "get",
            async:false,
            success : function(data) {
                deptList = data;
            }
        });
    }
    loadDeptList();
    function getDeptNameById(id){//根据科室id获取科室名称
        for (let i = 0; i < deptList.length; i++) {
            if(deptList[i].deptId==id){
                return deptList[i].name;
            }
        }
    }


    loadDocList();

</script>

</body>
</html>